package com.maben.udp.V1.service.impl;

import com.maben.udp.V1.service.UdpIntegrationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.ip.udp.UnicastSendingMessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Service;

/**
 * udpIntegration业务实现类
 */
@Service
@Slf4j(topic = "m.UdpIntegrationServiceImpl")
public class UdpIntegrationServiceImpl implements UdpIntegrationService {
    @Autowired
    private UnicastSendingMessageHandler unicastSendingMessageHandler;

    public void sendMessage(String message) {
        log.info("发送UDP: {}", message);
        unicastSendingMessageHandler.handleMessage(MessageBuilder.withPayload(message).build());
        log.info("发送成功");
    }
}
